<html>
<head><meta charset="utf-8"><title>shuffle naming · project-portable-simd · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/index.html">project-portable-simd</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html">shuffle naming</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="241594019"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241594019" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241594019">(Jun 04 2021 at 21:15)</a>:</h4>
<p>Uhhh <span class="user-mention" data-user-id="281757">@Jubilee</span> is there a reason we don't have single argument shuffle like this line form <code>packed_simd</code>?</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">tmp1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">shuffle</span><span class="o">!</span><span class="p">(</span><span class="n">tmp1</span><span class="p">,</span><span class="w"> </span><span class="p">[</span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w"> </span><span class="mi">1</span><span class="p">]);</span><span class="w"></span>
</code></pre></div>



<a name="241594055"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241594055" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241594055">(Jun 04 2021 at 21:15)</a>:</h4>
<p>I think I can do </p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="kd">let</span><span class="w"> </span><span class="n">tmp1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">f32x4</span>::<span class="n">shuffle</span>::<span class="o">&lt;</span><span class="p">{[</span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w"> </span><span class="mi">1</span><span class="p">]}</span><span class="o">&gt;</span><span class="p">(</span><span class="n">tmp1</span><span class="p">,</span><span class="w"> </span><span class="n">tmp1</span><span class="p">);</span><span class="w"></span>
</code></pre></div>
<p>for now but that's a bit ugly.</p>



<a name="241594196"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241594196" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241594196">(Jun 04 2021 at 21:16)</a>:</h4>
<blockquote>
<p>Uhhh <span class="user-mention silent" data-user-id="281757">Jubilee</span> is there a reason we don't have single argument shuffle like this line form <code>packed_simd</code>?</p>
</blockquote>
<p>because a macro is how we do variadics in Rust, and we didn't agree on the API for a single-vector form. ^^;</p>



<a name="241594386"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241594386" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241594386">(Jun 04 2021 at 21:17)</a>:</h4>
<p>Ok, I haven't read the issue, but it seems that if the 2-arg works, the 1-arg version could just be</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="kd">let</span><span class="w"> </span><span class="n">tmp1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">f32x4</span>::<span class="n">shuffle</span>::<span class="o">&lt;</span><span class="p">{[</span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w"> </span><span class="mi">1</span><span class="p">]}</span><span class="o">&gt;</span><span class="p">(</span><span class="n">tmp1</span><span class="p">);</span><span class="w"></span>
</code></pre></div>
<p>right?</p>



<a name="241594534"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241594534" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241594534">(Jun 04 2021 at 21:19)</a>:</h4>
<p>nope, because functions can't be variadic. ^^;;;</p>



<a name="241594561"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241594561" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241594561">(Jun 04 2021 at 21:20)</a>:</h4>
<p>we'd have to name them differently.</p>



<a name="241594564"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241594564" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241594564">(Jun 04 2021 at 21:20)</a>:</h4>
<p>...</p>



<a name="241594631"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241594631" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241594631">(Jun 04 2021 at 21:20)</a>:</h4>
<p>so yes if it's shuffle1 and shuffle2</p>



<a name="241594701"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241594701" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241594701">(Jun 04 2021 at 21:21)</a>:</h4>
<p>(ノಠ益ಠ)ノ彡┻━┻</p>



<a name="241594703"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241594703" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241594703">(Jun 04 2021 at 21:21)</a>:</h4>
<p>Fine.</p>



<a name="241594726"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241594726" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241594726">(Jun 04 2021 at 21:21)</a>:</h4>
<p>But I'm pouting.</p>



<a name="241594750"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241594750" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241594750">(Jun 04 2021 at 21:21)</a>:</h4>
<p>iktf</p>



<a name="241594805"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241594805" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241594805">(Jun 04 2021 at 21:22)</a>:</h4>
<p>I'm guessing I'll do my crappy fix for now and people can PR the nicer syntax once the bikeshedding is done.</p>



<a name="241594938"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241594938" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241594938">(Jun 04 2021 at 21:23)</a>:</h4>
<p>time to paint the bikeshed folks, why not <a href="https://www.youtube.com/watch?v=yKNxeF4KMsY">yellow</a>?</p>
<div class="youtube-video message_inline_image"><a data-id="yKNxeF4KMsY" href="https://www.youtube.com/watch?v=yKNxeF4KMsY"><img src="https://uploads.zulipusercontent.net/cfd0663b6c61ddf8f55ab3ea7bd894d412f2d015/68747470733a2f2f692e7974696d672e636f6d2f76692f794b4e786546344b4d73592f64656661756c742e6a7067"></a></div>



<a name="241600512"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241600512" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241600512">(Jun 04 2021 at 22:33)</a>:</h4>
<p>I think we should name the two-argument shuffle <code>shuffle2</code> and the one-argument shuffle <code>shuffle</code>, I'd expect the one-argument form to be used much more often.</p>



<a name="241601003"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241601003" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241601003">(Jun 04 2021 at 22:41)</a>:</h4>
<p>Can macros be namespaced so that <code>f32x4::shuffle!::&lt;{{1,2,3,4]}&gt;(arr1);</code> works?</p>



<a name="241601511"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241601511" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241601511">(Jun 04 2021 at 22:51)</a>:</h4>
<p>Answer: SO says <a href="https://stackoverflow.com/questions/24794821/is-it-possible-to-namespace-rust-macros">no</a>.</p>



<a name="241601543"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241601543" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241601543">(Jun 04 2021 at 22:51)</a>:</h4>
<p>well actually</p>



<a name="241601548"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241601548" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241601548">(Jun 04 2021 at 22:51)</a>:</h4>
<p>I think I agree, permutation seems way more common</p>



<a name="241601551"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241601551" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241601551">(Jun 04 2021 at 22:51)</a>:</h4>
<p>NO DON'T YOU START</p>



<a name="241601586"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241601586" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241601586">(Jun 04 2021 at 22:52)</a>:</h4>
<p>oh sorry <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="241601612"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241601612" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241601612">(Jun 04 2021 at 22:52)</a>:</h4>
<p>We now have a namespaced macro, and ongoing discussions of what should be namespaced: <a href="https://github.com/rust-lang/rust/issues/84019">https://github.com/rust-lang/rust/issues/84019</a></p>



<a name="241601651"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241601651" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241601651">(Jun 04 2021 at 22:53)</a>:</h4>
<p>I don't get why functions can't be variadic though <span aria-label="confused" class="emoji emoji-1f615" role="img" title="confused">:confused:</span></p>



<a name="241602132"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241602132" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241602132">(Jun 04 2021 at 23:01)</a>:</h4>
<p>My Rust training leads me to believe this should be possible:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="fm">macro_rules!</span><span class="w"> </span><span class="n">shuffle</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="p">(</span><span class="cp">$type</span>:<span class="nc">expr</span><span class="p">,</span><span class="w"> </span><span class="cp">$arr</span>:<span class="nc">expr</span><span class="p">,</span><span class="w"> </span><span class="cp">$arg1</span>:<span class="nc">expr</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="cp">$type</span>::<span class="n">shuffle1</span>::<span class="o">&lt;</span><span class="p">{</span><span class="cp">$arr</span><span class="p">}</span><span class="o">&gt;</span><span class="p">(</span><span class="n">arg1</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="p">};</span><span class="w"></span>
<span class="w">    </span><span class="p">(</span><span class="cp">$type</span>:<span class="nc">expr</span><span class="p">,</span><span class="w"> </span><span class="cp">$arr</span>:<span class="nc">expr</span><span class="p">,</span><span class="w"> </span><span class="cp">$arg1</span>:<span class="nc">expr</span><span class="p">,</span><span class="w"> </span><span class="cp">$arg2</span>:<span class="nc">expr</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="cp">$type</span>::<span class="n">shuffle2</span>::<span class="o">&lt;</span><span class="p">{</span><span class="cp">$arr</span><span class="p">}</span><span class="o">&gt;</span><span class="p">(</span><span class="n">arg1</span><span class="p">,</span><span class="w"> </span><span class="n">arg2</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="p">};</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="241602223"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241602223" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241602223">(Jun 04 2021 at 23:03)</a>:</h4>
<p>and then this Should Work <span aria-label="tm" class="emoji emoji-2122" role="img" title="tm">:tm:</span> :</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="kd">let</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">shuffle</span><span class="o">!</span><span class="p">(</span><span class="n">f32x4</span><span class="p">,</span><span class="w"> </span><span class="p">[</span><span class="mi">0</span><span class="p">,</span><span class="w"> </span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p">],</span><span class="w"> </span><span class="n">arr1</span><span class="p">);</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="n">c</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">shuffle</span><span class="o">!</span><span class="p">(</span><span class="n">f32x4</span><span class="p">,</span><span class="w"> </span><span class="p">[</span><span class="mi">0</span><span class="p">,</span><span class="w"> </span><span class="mi">5</span><span class="p">,</span><span class="w"> </span><span class="mi">7</span><span class="p">,</span><span class="w"> </span><span class="mi">3</span><span class="p">],</span><span class="w"> </span><span class="n">arr1</span><span class="p">,</span><span class="w"> </span><span class="n">arr2</span><span class="p">);</span><span class="w"></span>
</code></pre></div>



<a name="241602330"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241602330" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241602330">(Jun 04 2021 at 23:05)</a>:</h4>
<p>Oh, you could also be a bit smarter with the match arms and check that the <code>arr</code> is of the proper size given the type right?</p>



<a name="241602416"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241602416" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241602416">(Jun 04 2021 at 23:06)</a>:</h4>
<p>That would work, it just comes down to how much it matters vs the API being confusing</p>



<a name="241602441"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241602441" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241602441">(Jun 04 2021 at 23:06)</a>:</h4>
<p>Having two shuffle functions isn't particularly confusing, if it was a lot then perhaps a macro would be easier</p>



<a name="241602517"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241602517" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241602517">(Jun 04 2021 at 23:08)</a>:</h4>
<p>I'm thinking about it and don't see much harm in just defining <code>shuffle1</code> and <code>shuffle2</code>.</p>



<a name="241602533"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241602533" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241602533">(Jun 04 2021 at 23:08)</a>:</h4>
<p>Maybe the biggest hurdle here is to just take an executive decision and run with it <span aria-label="crab" class="emoji emoji-1f980" role="img" title="crab">:crab:</span></p>



<a name="241602582"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241602582" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241602582">(Jun 04 2021 at 23:09)</a>:</h4>
<p>Up to now, I'm fine with whatever people go for. Maybe not macros because they're a bit harder to debug for beginner users but <span aria-label="shrug" class="emoji emoji-1f937" role="img" title="shrug">:shrug:</span></p>



<a name="241602585"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241602585" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241602585">(Jun 04 2021 at 23:09)</a>:</h4>
<p>I think I'd prefer <code>shuffle</code> over <code>shuffle1</code> because it's a reasonable assumption that it operates on just one</p>



<a name="241602916"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241602916" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241602916">(Jun 04 2021 at 23:15)</a>:</h4>
<p>As a naïve newcomer to SIMD stuff, I was surprised that shuffle (in cranelift) took two vectors.  I totally expected "shuffle" to just rearrange a single vector.</p>



<a name="241603019"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241603019" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241603019">(Jun 04 2021 at 23:17)</a>:</h4>
<p>Hmm, maybe <code>permute</code> for 1-param and <code>shuffle</code> for 2-param?  (Based on <code>_mm256_permute_pd</code> and such.)</p>



<a name="241603102"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241603102" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241603102">(Jun 04 2021 at 23:18)</a>:</h4>
<p>I think permute is a misnomer since you can duplicate lanes</p>



<a name="241603214"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241603214" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241603214">(Jun 04 2021 at 23:20)</a>:</h4>
<p>Not that "shuffle" indicates that you can, but it's not as strict as "permute"</p>



<a name="241604142"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241604142" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241604142">(Jun 04 2021 at 23:34)</a>:</h4>
<p>Was going to say, yeah.  And <a href="https://en.cppreference.com/w/cpp/algorithm/shuffle">https://en.cppreference.com/w/cpp/algorithm/shuffle</a> is also a permutation...</p>



<a name="241604178"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241604178" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241604178">(Jun 04 2021 at 23:35)</a>:</h4>
<p>I think in common English shuffle and permute mean the same thing so as much as it pains me to say it, C++ is probably right</p>



<a name="241604227"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241604227" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241604227">(Jun 04 2021 at 23:36)</a>:</h4>
<p>I'm not sure there's a good word for what we're trying to do, but shuffle is pretty close</p>



<a name="241604239"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241604239" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241604239">(Jun 04 2021 at 23:36)</a>:</h4>
<p><code>reorder</code>?</p>



<a name="241604250"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241604250" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241604250">(Jun 04 2021 at 23:37)</a>:</h4>
<p>But maybe <code>shuffle</code> is too established in SIMD-land and you gotta respect it.</p>



<a name="241604302"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241604302" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241604302">(Jun 04 2021 at 23:38)</a>:</h4>
<p>Technically we aren't doing anything with order at all, a shuffle could just as easily be a blend or a broadcast</p>



<a name="241604337"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241604337" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241604337">(Jun 04 2021 at 23:38)</a>:</h4>
<p>A "splat" I should say</p>



<a name="241604378"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241604378" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241604378">(Jun 04 2021 at 23:39)</a>:</h4>
<p>But yes, shuffle is probably the most well known term for it</p>



<a name="241604879"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241604879" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241604879">(Jun 04 2021 at 23:49)</a>:</h4>
<p>Any way we slice it, we're using a term of art.</p>



<a name="241606947"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241606947" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241606947">(Jun 05 2021 at 00:35)</a>:</h4>
<p>call it elgguhs and no one will have any preconceived notions.</p>



<a name="241606949"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241606949" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241606949">(Jun 05 2021 at 00:35)</a>:</h4>
<p>well, if we really want a word that doesn't imply just reordering, how about swizzle? that's what's used in many GPU APIs</p>



<a name="241607072"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241607072" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241607072">(Jun 05 2021 at 00:38)</a>:</h4>
<p><a href="https://www.khronos.org/opengl/wiki/Data_Type_(GLSL)#Swizzling">https://www.khronos.org/opengl/wiki/Data_Type_(GLSL)#Swizzling</a></p>



<a name="241607233"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241607233" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241607233">(Jun 05 2021 at 00:42)</a>:</h4>
<p>oh, actually, yes i've used that before. solid choice</p>



<a name="241607242"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241607242" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241607242">(Jun 05 2021 at 00:43)</a>:</h4>
<p>just imagine how cool it would be if we could have swizzle syntax some day :3c</p>



<a name="241608059"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241608059" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241608059">(Jun 05 2021 at 01:04)</a>:</h4>
<p>I'm probably okay with swizzle too</p>



<a name="241608104"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241608104" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241608104">(Jun 05 2021 at 01:05)</a>:</h4>
<p><a href="https://en.wikipedia.org/wiki/Swizzling_(computer_graphics)">https://en.wikipedia.org/wiki/Swizzling_(computer_graphics)</a></p>



<a name="241608106"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241608106" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241608106">(Jun 05 2021 at 01:05)</a>:</h4>
<p>Wikipedia seems to indicate this is the correct word</p>



<a name="241608146"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241608146" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241608146">(Jun 05 2021 at 01:06)</a>:</h4>
<p>"rearranging and combining"</p>



<a name="241609067"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241609067" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241609067">(Jun 05 2021 at 01:33)</a>:</h4>
<p>we'd definitely want doc aliases for shuffle and permute, though</p>



<a name="241615323"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241615323" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241615323">(Jun 05 2021 at 04:28)</a>:</h4>
<p>there are a few other uses of the term "swizzling" for completely unrelated reasons (pointer swizzling mostly, but even in gpu terms it can refer to the various memory layout tricks done on textures, for example <a href="https://fgiesen.wordpress.com/2011/01/17/texture-tiling-and-swizzling/">https://fgiesen.wordpress.com/2011/01/17/texture-tiling-and-swizzling/</a>), but it's probably unambiguous enough.</p>
<p>that said, i think prefer shuffle since its ubiquitous, and is a term that's pretty close to the correct idea. swizzle is honestly just complete jargon if you dont know what it means already</p>



<a name="241615402"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241615402" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241615402">(Jun 05 2021 at 04:31)</a>:</h4>
<p>I had never heard of the term before and it sounds like something from Willy Wonka.</p>



<a name="241620181"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241620181" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241620181">(Jun 05 2021 at 06:41)</a>:</h4>
<p>Well, "Swizzle Sticks" are from 18th century rum plantations, apparently (TIL) &lt;<a href="https://en.wikipedia.org/wiki/Swizzle_stick">https://en.wikipedia.org/wiki/Swizzle_stick</a>&gt;</p>
<p>Some prior art: WASM SIMD apparently uses swizzle for one-vector and shuffle for two-vector, based on &lt;<a href="https://github.com/stoklund/portable-simd/blob/master/portable-simd.md#swizzle-lanes">https://github.com/stoklund/portable-simd/blob/master/portable-simd.md#swizzle-lanes</a>&gt; and &lt;<a href="https://github.com/WebAssembly/simd/blob/main/proposals/simd/ImplementationStatus.md">https://github.com/WebAssembly/simd/blob/main/proposals/simd/ImplementationStatus.md</a>&gt;</p>
<p>So following that might be reasonable, absent any stronger feelings.</p>



<a name="241672225"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241672225" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241672225">(Jun 06 2021 at 04:36)</a>:</h4>
<p>I do think we should pick one of swizzle or shuffle (or something else), but I am against using both words at once, one-arg swizzle should <em>not</em> arbitrarily have a different name than two-arg swizzle. The names should be like <code>swizzle</code> and <code>swizzle2</code> or similar such that anyone can tell just by glancing at the names that <code>swizzle2</code> is just like <code>swizzle</code> except it has two args.</p>



<a name="241726800"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241726800" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241726800">(Jun 07 2021 at 04:15)</a>:</h4>
<p>I feel like we've made an effort to make names that aren't jargony so far, and swizzle is entirely jargon, so IMO we shouldn't use it if we're going to stick with our current conventions.</p>



<a name="241726932"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241726932" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241726932">(Jun 07 2021 at 04:18)</a>:</h4>
<p>I don't think it's any worse than <code>splat</code>--it's jargon but generally accepted</p>



<a name="241812908"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/241812908" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#241812908">(Jun 07 2021 at 17:37)</a>:</h4>
<p>I don't mind a jargony name -- if I can lookup <em>simd frobble</em> in a search engine and get a reasonable result, that might actually better than a non-jargon name that nobody else uses and thus might actually be more confusing.</p>
<p>(Like how my suggestion of <code>permute</code> above would erroneously imply "no repetition/removal" in a way that it shouldn't, even though <code>shuffle</code> also implies that in normal English, but because it's existing jargon that might be ok.)</p>



<a name="242013810"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/242013810" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#242013810">(Jun 09 2021 at 03:20)</a>:</h4>
<p>It sounds like we're all basically against permute, which is fine by me.<br>
Jacob brought up a fair point that, if we're going to use jargon, we shouldn't bring up two basically interchangeable forms of jargon, so let's not use both swizzle and shuffle. Which I agree with.</p>
<p>I think we're basically settled on "swizzle XOR shuffle", then?</p>



<a name="242014851"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/242014851" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#242014851">(Jun 09 2021 at 03:42)</a>:</h4>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span> might have some thought here -- I see they were mentioned in <a href="https://github.com/WebAssembly/simd/issues/78">https://github.com/WebAssembly/simd/issues/78</a> related to <a href="https://github.com/WebAssembly/simd/pull/71#issuecomment-472691503">https://github.com/WebAssembly/simd/pull/71#issuecomment-472691503</a></p>
<p>WASM may well have different tradeoffs than we do, but there's also much to be said for stealing another project's bikeshed wallpaper ;)</p>



<a name="242236288"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/242236288" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#242236288">(Jun 10 2021 at 16:48)</a>:</h4>
<p><span class="user-mention" data-user-id="281757">@Jubilee</span> I personally find shuffle to be a term I'd automatically assume a more regular meaning for (intuition may give the right answer), while swizzle is a term I would expect to have a more unusual specialized meaning (intuition may give the wrong answer).</p>



<a name="242236422"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/242236422" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#242236422">(Jun 10 2021 at 16:49)</a>:</h4>
<p>I've also occasionally seen both used with different meanings (lanes vs bits within lanes).</p>



<a name="242236530"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/242236530" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#242236530">(Jun 10 2021 at 16:50)</a>:</h4>
<p>And I've also seen swizzle used to mean something <em>completely</em> different (a reversible transformation of bits, such as xor with a constant).</p>



<a name="242238175"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/242238175" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#242238175">(Jun 10 2021 at 17:01)</a>:</h4>
<p>I think my concern here is that people might expect "shuffle" to mean "randomize these".</p>



<a name="242248296"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/242248296" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#242248296">(Jun 10 2021 at 18:15)</a>:</h4>
<p>I agree that shuffle is somewhat more "natural" but I expect more collisions due to that.<br>
I think more people will view swizzle as pure "term of art".<br>
I'm OK with either though because unlike String vs. StrBuf, where I feel we definitely made the wrong choice and it should've been StrBuf :^), it doesn't feel to me like there's a purely "obvious" choice, because there's no super consistent background here, not in Rust or elsewhere. Lotta variation.</p>



<a name="242248605"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/242248605" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#242248605">(Jun 10 2021 at 18:17)</a>:</h4>
<p>Well, if we get a special syntax form of it, we'll all be calling it swizzle syntax, not shuffle syntax.<br>
By convention.</p>



<a name="242248643"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/242248643" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#242248643">(Jun 10 2021 at 18:18)</a>:</h4>
<p>But that might be distinct, functionally, in some way, from the functions. Though as I noted:</p>
<blockquote>
<p>...it's too bad we don't have IndexGet.<br>
Then swizzle could just be indicing with an array.</p>
</blockquote>



<a name="242254010"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/242254010" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#242254010">(Jun 10 2021 at 18:57)</a>:</h4>
<p>Yeah I vote swizzle. The fact that it's slightly weird <em>is the benefit</em> here. People should pause a moment and see "what do they mean by that exactly?"</p>



<a name="242377711"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/242377711" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#242377711">(Jun 11 2021 at 17:31)</a>:</h4>
<p>For clarity, I was <em>not</em> arguing that shuffle was the better term or that swizzle wasn't. I was just providing some background from my own exposure to the two terms, insofar as one feels like it has some semantics attached and the other doesn't.</p>



<a name="242377816"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/242377816" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#242377816">(Jun 11 2021 at 17:32)</a>:</h4>
<p>I was more trying to make the case for "we should use shuffle if and only if we match what people will expect for shuffle; we should use swizzle if we want people to have to learn what we mean by that and not make any assumptions".</p>



<a name="242377955"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/242377955" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#242377955">(Jun 11 2021 at 17:33)</a>:</h4>
<p><span class="user-mention silent" data-user-id="281757">Jubilee</span> <a href="#narrow/stream/257879-project-portable-simd/topic/shuffle.20naming/near/242238175">said</a>:</p>
<blockquote>
<p>I think my concern here is that people might expect "shuffle" to mean "randomize these".</p>
</blockquote>
<p>I would expect that to be called "random_shuffle", insofar as a random shuffle is a shuffle but a shuffle isn't necessarily a random shuffle.</p>



<a name="242380258"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/242380258" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#242380258">(Jun 11 2021 at 17:51)</a>:</h4>
<p>Well, in my experience with <code>shuffle</code>, people incorrectly assume the result must be a permutation of the input vector and that no duplicating/ignoring input vector elements is allowed. I think going with <code>swizzle</code> may be better because people are likely to not make that incorrect assumption.</p>



<a name="242409492"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/242409492" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#242409492">(Jun 11 2021 at 22:05)</a>:</h4>
<p>I mean there's always <code>tbl</code>. &lt;_&lt;;</p>



<a name="242409622"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/242409622" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#242409622">(Jun 11 2021 at 22:06)</a>:</h4>
<p>You're kind of joking, I think, but it really is basically a LUT</p>



<a name="242409820"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/shuffle%20naming/near/242409820" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/shuffle.20naming.html#242409820">(Jun 11 2021 at 22:09)</a>:</h4>
<p><code>fn lut</code> pffthaha</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>